{# vim: set et ts=8 sts=4 sw=4 ai: #}
{% extends "wiki.html" %}
{% block navbarsearch %}
{# don't display two searchbars #}
{% endblock %}
{% block content %}
<div class="w-600 mw-full">
<div class="card">
  <h2 class="card-title">Search</h2>
  <form action="{{url_for("search")}}" method="POST" class="form-inline">
  <div class="form-group">
    <input type="text" class="form-control" name="query" id="search-query" placeholder="Search term" value="{{query if query}}" autofocus onfocus="this.setSelectionRange(this.value.length,this.value.length);">
  </div>
{#
  <div class="form-group">
    <div class="form-text">
        <strong>Hint:</strong>&nbsp;Avoid abbreviations. Try to limit your name to three simple words or fewer.
    </div>
  </div>
#}
  <div class="form-group">
  <div class="custom-checkbox d-inline-block mr-10">
    <input type="checkbox" id="is_casesensitive" name="is_casesensitive" value="y" {{"checked" if is_casesensitive}}>
    <label for="is_casesensitive">Match case</label>
  </div>
  <div class="custom-checkbox d-inline-block mr-10">
    <input type="checkbox" id="regexp" name="is_regexp" value="y" {{"checked" if is_regexp}}>
    <label for="regexp">Regular expression</label>
  </div>
{#
  <div class="custom-checkbox d-inline-block">
    <input type="checkbox" id="in_history" name="in_history" value="y" {{"checked" if in_history}}>
    <label for="in_history">Search in history</label>
  </div>
#}
  </div>
  <div class="form-group">
    <input class="btn btn-primary" type="submit" value="Search">
  </div>
</form>
</div>{# card #}
</div>{# w-600 container #}
{#
#}
{% if result %}
<h1 class="content-title">Search matched {{keys | length}} page{%if keys | length >1%}s{%endif%}:</h1>
{% for key in keys %}
<h2 class="content-title mt-20"><a href="{{ url_for('view', path=key[3]) }}">{{key[4]|safe}}</a>
{%- if key[0] == key[1] == 1 %}
(Name matches)
{% elif key[0] == 1  %}
(Name and {{key[1] - 1}} match{%if key[1] -1 != 1%}es{%endif%} found)</h2>
{% else %}
({{key[1]}} match{%if key[1]!=1%}es{%endif%} found)</h2>
{% endif -%}
{% for match in result[key] %}
{%- if match -%}
<p>{{match|safe}}</p>
{%- endif -%}
{%- endfor -%}
{% endfor %}
{% else %}
<h1 class="content-title">No match found.</h1>
{% endif %}
{% endblock %}
